package communication.server;

import communication.client.Client;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;


public class Server {

    ServerSocket serverSocket;
    Socket accept;
    BufferedInputStream bis;
    BufferedOutputStream bos;
    Map<String, Client> map = new HashMap<>();


    public void start() {
        //1，画界面

        //2,创建服务器套接字，连接客户端
        this.createServerSocket();

        //开启读线程
        while (true) {
            new Thread(new ServerRead(accept, map));
        }

    }
    //创建服务器套接字
    public void createServerSocket() {
        try {
            serverSocket = new ServerSocket(8080);
            accept = serverSocket.accept();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
